package com.action;

import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bean.ResponseBean;
import com.pojo.Admin;
import com.pojo.UserInfo;
import com.service.AdminService;
import com.service.DictionaryService;
import com.service.JifenChongzhiService;
import com.service.UserInfoService;
import com.util.JwtUtil;
import com.util.PinYinJPUtil;
import com.util.StringUtil;
import com.util.ValidateHelper;
import com.vo.UserInfoVo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Description:
 * @Auther: tz
 * @Date: 2023/11/9 10:51
 */
@CrossOrigin
@RestController
@RequestMapping("/userInfo")
public class UserInfoAction {

    @Value("${upload.dir}")
    private String upload;

    @Value("${upload.tmp.dir}")
    private String tmp;

    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private AdminService adminService;

    @Autowired
    private DictionaryService dictionaryService;

    @Autowired
    private JifenChongzhiService jifenChongzhiService;

    @Autowired
    @Qualifier("redisTemplate")
    private RedisTemplate redisTemplate;

    /**
     * 生日提醒
     * @return
     */
    @RequestMapping("/getShengriTixing")
    public ResponseBean getShengriTixing() throws ParseException {
        com.pojo.Dictionary dictionary = dictionaryService.getDicByCode("user","birthdays");
        if (dictionary == null){
            return ResponseBean.error("数据字典无数据");
        }
        List<UserInfo> userInfoList = userInfoService.list();
        String names = "";
//        Date time = DateUtil.getAddDayTime(new Date(),Integer.parseInt(dictionary.getValue()));
        Calendar calendar = Calendar.getInstance();
        int month = calendar.get(Calendar.MONTH) + 1;
        LocalDate now = LocalDate.now();
        int day = now.getDayOfMonth();
        for (UserInfo userInfo : userInfoList){
            String[] tims = userInfo.getCstime().split("/");
            if (tims.length == 3){
                int mon = Integer.parseInt(tims[1]);
                int da = Integer.parseInt(tims[2]);
                if (day == da){
                    if ((month==12 && mon==1) || ((month+1)==mon)){
                        if (StringUtil.isNull(names)){
                            names = names + userInfo.getName();
                        }else{
                            names = names + "、" + userInfo.getName();
                        }
                    }
                }
            }
//            DateFormat fmt =  new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
//            Date startTime = fmt.parse(userInfo.getCstime() + " 00:00:00");
//            Date endTime = fmt.parse(userInfo.getCstime() + " 23:59:59");
//            if (time.compareTo(startTime) > 0 && time.compareTo(endTime) < 0){
//                if (StringUtil.isNull(names)){
//                    names = names + userInfo.getName();
//                }else{
//                    names = names + "," + userInfo.getName();
//                }
//            }
        }
        if (StringUtil.isNull(names)){
            return ResponseBean.error("没有会员生日提醒");
        }
        return new ResponseBean(200,"有生日提醒",names+"将于"+dictionary.getValue()+"天后生日");
    }

    /**
     * 充值积分
     * @param id
     * @param jine
     * @return
     */
    @RequestMapping("/czJifen")
    public ResponseBean czJifen(String id, String jine, @RequestHeader(value = "token" , required = false) String token){
        String msg = adminService.verifyToken(token);
        if (StringUtil.isNotNull(msg)){
            return ResponseBean.error(msg);
        }
        String uid = JwtUtil.getUsername(token);
        Admin admin = adminService.getById(uid);
        if(admin == null){
            return ResponseBean.error("请先登录！");
        }
        UserInfo userInfo = userInfoService.getById(id);
        if (userInfo == null){
            return ResponseBean.error("缺少必填参数！");
        }
        com.pojo.Dictionary dictionary = dictionaryService.getDicByCode("user","integralFormula");
        if (dictionary == null){
            return ResponseBean.error("字典表没有积分公式");
        }
        BigDecimal jin = new BigDecimal(jine);
        BigDecimal min = new BigDecimal(dictionary.getValue());
        if (jin.compareTo(min) == -1){
            return ResponseBean.error("充值金额不能小于"+dictionary.getValue()+"人民币");
        }
        BigDecimal jifen = jin.divide(min,2,BigDecimal.ROUND_DOWN);
        userInfo.setJifen(userInfo.getJifen().add(jifen));
        if (userInfoService.updateById(userInfo)){
            //写充值记录
            jifenChongzhiService.addJifenChongzhi(id,jin,userInfo.getJifen(),admin.getId(),admin.getUsername(),1);
            return ResponseBean.ok("充值成功");
        }
        return ResponseBean.error("充值失败");
    }

    /**
     * 获取导出任务的结果，从redis中取
     * @param times 时间戳
     * @return
     */
    @PostMapping("/getExportUserInfoResult")
    public ResponseBean getExportUserInfoResult(String times, HttpServletResponse response) throws IOException {
        if (StringUtil.isNull(times)){
            return new ResponseBean(500,"参数异常",null);
        }
        String result = (String) redisTemplate.boundHashOps("isFineshed").get("status"+times);
        Map map = new HashMap() ;
        map.put("status" , result) ;
        if ("1".equals(result)) {
            String work = (String) redisTemplate.opsForValue().get("work"+times);
            map.put("downloadUrl" , work) ;
        }
        return new ResponseBean(200,"ok",map);
    }

    /**
     * 挂失补卡会员列表
     * @param name       姓名
     * @param page       页数
     * @param limit      每页条数
     * @param cardStatus 卡状态
     * @return
     */
    @RequestMapping("/selectstaffGsBk")
    public ResponseBean selectstaffGsBk(String name, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit,
                                        @RequestParam(required = false) String cardStatus) {
        IPage<UserInfoVo> staffList = userInfoService.selectStaffByCard(name, page, limit, cardStatus);
        return new ResponseBean(0, staffList.getTotal(), "成功", staffList.getRecords());
    }

    /**
     * 解除卡的绑定关系
     * @return
     */
    @RequestMapping("reset_card")
    public ResponseBean resetCard(String id) {
        String res = userInfoService.resetCard(id);
        return res != null ? ResponseBean.error(res) : ResponseBean.OK;
    }

    /**
     * 绑定卡与用户关系
     * @param uid
     * @param cid
     * @return
     */
    @RequestMapping("bangdin")
    public ResponseBean bangdin(String uid, String cid) {
        String res = userInfoService.bangdin(uid, cid);
        return res != null ? ResponseBean.error(res) : ResponseBean.OK;
    }

    /**
     * 绑定卡与用户关系
     * @param cid
     * @return
     */
    @RequestMapping("bangdin1")
    public ResponseBean bangdin1(String cid) {
        String res = userInfoService.bangdin1(cid);
        return res != null ? ResponseBean.error(res) : ResponseBean.OK;
    }

    /**
     * 判断会员与卡号是否匹配
     * @param id
     * @return
     */
    @RequestMapping("/getStaffByCard")
    public ResponseBean getStaffByCard(String cardNo, String id) {
        int result = userInfoService.getStaffByCard(cardNo, id);
        if (result == 1) {
            return new ResponseBean(500, "会员与卡号不匹配，请联系开发者", "会员与卡号不匹配，请联系开发者");
        } else if (result == 0) {
            return new ResponseBean(500, "白卡", "白卡");
        }
        return new ResponseBean(200, "获取成功", "获取成功");
    }

    /**
     * 根据id查询会员信息
     * @param id
     * @return
     */
    @RequestMapping("staff_id")
    @ResponseBody
    public ResponseBean getStaffById(String id) {
        UserInfo staff = userInfoService.getById(id);
        if (staff.getCardBalance() == null) {
            staff.setCardBalance(new BigDecimal(0));
            userInfoService.updateById(staff);
        }
        String res = userInfoService.checkBh(id);
        if (ValidateHelper.isNotEmptyString(res)) {
            return new ResponseBean(500, "问题数据过滤", "问题数据过滤");
        }
        return new ResponseBean(200, "成功", userInfoService.getById(id));
    }

    /**
     * 获取UUID
     */
    @RequestMapping("/getUUid")
    public ResponseBean getUUid() {
        String random = UUID.randomUUID().toString();
        redisTemplate.opsForValue().set("kk" + random, random, 2 * 60, TimeUnit.SECONDS);
        Map result = new HashMap();
        result.put("kk", random);
        return new ResponseBean(1, 1, "生成随机数成功", result);
    }

    /**
     * 分页查询未开卡会员
     * @param name
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("/selectUserInfoByWkk")
    public ResponseBean selectUserInfoByWkk(String name, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) {
        IPage iPage = userInfoService.selectUserInfoByWkk(page, limit, name);
        return new ResponseBean(0, iPage.getTotal(), "成功", iPage.getRecords());
    }

    /**
     * 根据会员ID查询会员信息
     * @param id
     * @return
     */
    @RequestMapping("/getUserInfoById")
    private ResponseBean getUserInfoById(String id){
        UserInfo userInfo = userInfoService.getById(id);
        if (userInfo == null){
            return ResponseBean.error("未找到会员！");
        }
        return new ResponseBean(200,"查询成功",userInfo);
    }

    /**
     * 分页查询会员
     * @param name  姓名
     * @param page  页数
     * @param limit 每页条数
     * @param zhiye 职业
     * @return
     */
    @RequestMapping("/userInfoList")
    public ResponseBean userInfoList(String name, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit, String zhiye) {
        IPage iPage = userInfoService.userInfoList(name, page, limit, zhiye);
        return new ResponseBean(0, iPage.getTotal(), "成功", iPage.getRecords());
    }

    /**
     * 判断证件号码是否已存在
     * @param sfz
     * @return
     */
    @RequestMapping("/sfzShifouExist")
    public ResponseBean sfzShifouExist(String sfz) {
        int x = userInfoService.sfzCount(sfz);
        return new ResponseBean(0, x, "", "");
    }

    /**
     * 修改会员信息
     * @param userInfo
     * @return
     * @throws ParseException
     */
    @RequestMapping("/updUserInfo")
    public ResponseBean updUserInfo(@RequestBody UserInfo userInfo) throws ParseException {
        if (StringUtil.isNull(userInfo.getPicture())) {
            userInfo.setPicture(null);
        }
        UserInfo sta = userInfoService.getById(userInfo.getId());
        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        String dateString = userInfo.getCstime();

        Date date = format.parse(dateString);
        if (sta.getCstime().startsWith("00")) {
            if (!sta.getCstime().equals(userInfo.getCstime())) {

                Pattern pattern1 = Pattern.compile("-?[0-9]+(\\\\.[0-9]+)?");
                Matcher mt1 = pattern1.matcher(userInfo.getName());
                if (mt1.matches()) {
                    return ResponseBean.error("姓名不能是纯数字！");
                }

                String str[] = dateString.split("/");
                String monthStr = "";
                String dayStr = "";
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(date);
                int month = calendar.get(Calendar.MONTH) + 1;
                int day = calendar.get(Calendar.DAY_OF_MONTH);
                // 获取出生年月，没有2位数则自动补0
                if (str[1].startsWith("0")) {
                    monthStr = str[1];
                } else {
                    monthStr = month >= 10 ? String.valueOf(month) : "0" + month;
                }
                if (str[2].startsWith("0")) {
                    dayStr = str[2];
                } else {
                    dayStr = day >= 10 ? String.valueOf(day) : "0" + day;
                }
                // 去数字
                String strNum = userInfo.getName().replaceAll("\\d+", "");
                // 去空格
                String strName1 = StringUtils.deleteWhitespace(strNum);
                String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，·、？]";
                Pattern pt = Pattern.compile(regEx);
                Matcher mc = pt.matcher(strName1);
                // 去掉名字中的特殊字符
                String newName = mc.replaceAll("").trim();
                String tmpName = newName;

                Pattern p = Pattern.compile("[\u4e00-\u9fa5]+");
                Matcher m = p.matcher(newName);
                String one = "";
                // 判断是否有中文
                if (m.find()) {
                    Pattern pattern = Pattern.compile("[^\u4E00-\u9FA5]");
                    Matcher matcher = pattern.matcher(newName);
                    // 获取所有中文
                    newName = matcher.replaceAll("");
                    newName = StringUtils.deleteWhitespace(newName);
                    // 中文个数
                    if (newName.length() > 1) {
                        // 截最后2位生成拼音首字母
                        newName = newName.substring(newName.length() - 2);
                        //newName = ChineseToEnglishUtil.getPinYinHeadChar(newName);
                        newName = PinYinJPUtil.changeToGetShortPinYin(newName);
                    } else if (newName.length() == 1) {
                        // 取一个汉字拼音的前2位
                        //newName = ChineseToEnglishUtil.getPingYin(newName);
                        newName = PinYinJPUtil.changeToTonePinYin(newName);
                        if (newName.length() == 1 && tmpName.length() > 1) {
                            Matcher m2 = p.matcher(tmpName);
                            if (m2.find()) {
                                Pattern pattern2 = Pattern.compile("[^\u4E00-\u9FA5]");
                                Matcher matcher2 = pattern2.matcher(tmpName);
                                // 获取所有中文
                                String tmpName1 = matcher2.replaceAll("");
                                String tmpName2 = StringUtils.deleteWhitespace(tmpName1);
                                // 获取中文之后的字符串
                                String str3 = tmpName.substring(0, tmpName.indexOf(tmpName2));
                                String str4 = tmpName.substring(str3.length() + 1, tmpName.length());
                                Pattern pt2 = Pattern.compile(regEx);
                                Matcher mc2 = pt2.matcher(str3);
                                // 去掉中文前面特殊字符
                                String str6 = mc2.replaceAll("").trim();

                                Pattern pt3 = Pattern.compile(regEx);
                                Matcher mc3 = pt3.matcher(str4);
                                // 去掉中文前面特殊字符
                                String str7 = mc3.replaceAll("").trim();
                                //判断前面是否有两个字符
                                if (str6.length() >= 2) {
                                    newName = str6.substring(0, 2);
                                } else {
                                    if (str7.length() > 1) {
                                        newName = newName + str7.substring(0, 1);  // lgh ------------------------
                                    } else if (str7.length() == 1) {
                                        newName = newName + str7;
                                    } else {
                                        return ResponseBean.error("姓名不符合规范");
                                    }
                                }
                            }
                        } else if (newName.length() == 1) {// 处理"啊"，"哦"，"额"单音
                            newName = newName + newName;
                        } else {
                            if (newName != null && newName.length() > 2) {
                                newName = newName.substring(0, 2);
                            }
                        }
                    }
                    // 中文名字转拼音首字母大写
                    one = newName.toUpperCase();
                } else if (Pattern.compile("[a-zA-Z]").matcher(newName).find()) {
                    newName = newName.replaceAll("[^a-zA-Z]", "");
                    if (newName.length() > 1) {
                        newName = newName.substring(0, 2);
                    } else if (newName.length() == 1) {
                        newName = newName + newName;
                    } else {
                        return ResponseBean.error("姓名不能为空");
                    }
                    one = newName.toUpperCase();
                } else if (Pattern.compile("[\u1000-\u109F]").matcher(newName).find()) {
                    one = "MD";
                } else if (Pattern.compile("[\u0E80-\u0EFF]").matcher(newName).find()) {
                    one = "LW";
                } else if (Pattern.compile("[\u0E00-\u0E7F]").matcher(newName).find()) {
                    one = "TG";
                }
                String four = monthStr + dayStr;
                String monthStr2 = "";
                if (monthStr.equals("10")) {
                    monthStr2 = "0" + monthStr;
                } else {
                    monthStr2 = monthStr;
                }
                String dayStr2 = "";
                if (dayStr.equals("10")) {
                    dayStr2 = "0" + dayStr;
                } else {
                    dayStr2 = dayStr;
                }
                String four2 = monthStr2 + dayStr2;
                int five = 1;
                int six = 0;
                if (userInfo.getSex() == 1) {
                    for (int j = 0; j < 10; j++) {
                        if (j % 2 == 0) {
                            continue;
                        }
                        six = j;
                        break;
                    }
                } else {
                    for (int j = 0; j < 10; j++) {
                        if (j % 2 == 0) {
                            six = j;
                            break;
                        }
                        continue;
                    }
                }
                String bh = one + four + five + six;
                String bh2 = one + four2;
                userInfo.setBh(bh);
                userInfo.setBh2(bh2);
            }
        }
        if (userInfoService.updateById(userInfo)) {
            if (StringUtil.isNotNull(userInfo.getPicture()) && userInfo.getPicture().equals(sta.getPicture()) == false) {
                FileUtil.copy(tmp + userInfo.getPicture(), upload, true);
            }
            return ResponseBean.ok("修改成功");
        } else {
            return ResponseBean.error("修改失败");
        }
    }

    /**
     * 新增会员
     * @param userInfo
     * @param token
     * @return
     */
    @RequestMapping("/addUserInfo")
    public ResponseBean addUserInfo(@RequestBody UserInfo userInfo, @RequestHeader(value = "token" , required = false) String token) throws ParseException {
        userInfo.setShstatus(1);
        if (null != userInfo) {
            String msg = adminService.verifyToken(token);
            if (StringUtil.isNotNull(msg)){
                return ResponseBean.error(msg);
            }
            String uid = JwtUtil.getUsername(token);
            userInfo.setOperUser(uid);
        }
        ResponseBean bean = addUser(userInfo);
        return bean;
    }

    private ResponseBean addUser(UserInfo userInfo) throws ParseException {

        Pattern pattern1 = Pattern.compile("-?[0-9]+(\\\\.[0-9]+)?");
        Matcher mt1 = pattern1.matcher(userInfo.getName());
        if (mt1.matches()) {
            return ResponseBean.error("姓名不能是纯数字！");
        }
        if (ValidateHelper.isNotEmptyString(userInfo.getSfz())) {

        }
        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        String dateString = userInfo.getCstime();
        Date date = format.parse(dateString);
        String str[] = dateString.split("/");
        String monthStr = "";
        String dayStr = "";
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int month = calendar.get(Calendar.MONTH) + 1;
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        // 获取出生年月，没有2位数则自动补0
        if (str[1].startsWith("0")) {
            monthStr = str[1];
        } else {
            monthStr = month >= 10 ? String.valueOf(month) : "0" + month;
        }
        if (str[2].startsWith("0")) {
            dayStr = str[2];
        } else {
            dayStr = day >= 10 ? String.valueOf(day) : "0" + day;
        }

        userInfo.setCstime(userInfo.getCstime());
        // 去数字
        String strNum = userInfo.getName().replaceAll("\\d+", "");
        // 去空格
        String strName1 = StringUtils.deleteWhitespace(strNum);
        String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，·、？]";
        Pattern pt = Pattern.compile(regEx);
        Matcher mc = pt.matcher(strName1);
        // 去掉名字中的特殊字符
        String newName = mc.replaceAll("").trim();
        String tmpName = newName;

        Pattern p = Pattern.compile("[\u4e00-\u9fa5]+");
        Matcher m = p.matcher(newName);
        String one = "";
        // 判断是否有中文
        if (m.find()) {
            Pattern pattern = Pattern.compile("[^\u4E00-\u9FA5]");
            Matcher matcher = pattern.matcher(newName);
            // 获取所有中文
            newName = matcher.replaceAll("");
            newName = StringUtils.deleteWhitespace(newName);
            // 中文个数
            if (newName.length() > 1) {
                // 截最后2位生成拼音首字母
                newName = newName.substring(newName.length() - 2);
                //newName = ChineseToEnglishUtil.getPinYinHeadChar(newName);
                newName = PinYinJPUtil.changeToGetShortPinYin(newName);
            } else if (newName.length() == 1) {
                // 取一个汉字拼音的前2位
                //newName = ChineseToEnglishUtil.getPingYin(newName);
                newName = PinYinJPUtil.changeToTonePinYin(newName);
                if (newName.length() == 1 && tmpName.length() > 1) {
                    Matcher m2 = p.matcher(tmpName);
                    if (m2.find()) {
                        Pattern pattern2 = Pattern.compile("[^\u4E00-\u9FA5]");
                        Matcher matcher2 = pattern2.matcher(tmpName);
                        // 获取所有中文
                        String tmpName1 = matcher2.replaceAll("");
                        String tmpName2 = StringUtils.deleteWhitespace(tmpName1);
                        // 获取中文之后的字符串
                        String str3 = tmpName.substring(0, tmpName.indexOf(tmpName2));
                        String str4 = tmpName.substring(str3.length() + 1, tmpName.length());
                        Pattern pt2 = Pattern.compile(regEx);
                        Matcher mc2 = pt2.matcher(str3);
                        // 去掉中文前面特殊字符
                        String str6 = mc2.replaceAll("").trim();

                        Pattern pt3 = Pattern.compile(regEx);
                        Matcher mc3 = pt3.matcher(str4);
                        // 去掉中文前面特殊字符
                        String str7 = mc3.replaceAll("").trim();
                        //判断前面是否有两个字符
                        if (str6.length() >= 2) {
                            newName = str6.substring(0, 2);
                        } else {
                            if (str7.length() > 1) {
                                newName = newName + str7.substring(0, 1);  // lgh ------------------------
                            } else if (str7.length() == 1) {
                                newName = newName + str7;
                            } else {
                                return ResponseBean.error("姓名不符合规范");
                            }
                        }
                    }
                } else if (newName.length() == 1) {// 处理"啊"，"哦"，"额"单音
                    newName = newName + newName;
                } else {
                    if (newName != null && newName.length() > 2) {
                        newName = newName.substring(0, 2);
                    }
                }
            }
            // 中文名字转拼音首字母大写
            one = newName.toUpperCase();
        } else if (Pattern.compile("[a-zA-Z]").matcher(newName).find()) {
            newName = newName.replaceAll("[^a-zA-Z]", "");
            if (newName.length() > 1) {
                newName = newName.substring(0, 2);
            } else if (newName.length() == 1) {
                newName = newName + newName;
            } else {
                return ResponseBean.error("姓名不能为空");
            }
            one = newName.toUpperCase();
        } else if (Pattern.compile("[\u1000-\u109F]").matcher(newName).find()) {
            one = "MD";
        } else if (Pattern.compile("[\u0E80-\u0EFF]").matcher(newName).find()) {
            one = "LW";
        } else if (Pattern.compile("[\u0E00-\u0E7F]").matcher(newName).find()) {
            one = "TG";
        }
        String four = monthStr + dayStr;
        String monthStr2 = "";
        if (monthStr.equals("10")) {
            monthStr2 = "0" + monthStr;
        } else {
            monthStr2 = monthStr;
        }
        String dayStr2 = "";
        if (dayStr.equals("10")) {
            dayStr2 = "0" + dayStr;
        } else {
            dayStr2 = dayStr;
        }
        String four2 = monthStr2 + dayStr2;
        int five = 1;
        int six = 0;
        if (userInfo.getSex() == 1) {
            for (int j = 0; j < 10; j++) {
                if (j % 2 == 0) {
                    continue;
                }
                six = j;
                break;
            }
        } else {
            for (int j = 0; j < 10; j++) {
                if (j % 2 == 0) {
                    six = j;
                    break;
                }
                continue;
            }
        }
        String bh = one + four + five + six;
        String bh2 = one + four2;

        userInfo.setBh(bh);
        userInfo.setBh2(bh2);
        userInfo.setDqtime(new Date());
        userInfo.setCreateTime(new Date());
        userInfo.setJfstatus(2);
        if (userInfoService.save(userInfo)) {
            if (StringUtil.isNotNull(userInfo.getPicture())) {
                FileUtil.copy(tmp + userInfo.getPicture(), upload, true);
            }
            return ResponseBean.ok("新增成功");
        }
        return ResponseBean.error("新增失败");
    }
}